package com.lixiaoyi.emp.controller;

import com.lixiaoyi.emp.entity.Emp;
import com.lixiaoyi.emp.service.IEmpService;
import com.lixiaoyi.emp.service.impl.EmpServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author 李小毅
 * @Description
 * @Date 2022-05-15
 */

@WebServlet("/manager/safe/addEmpController")
public class addEmpController extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //1.收参
        Integer id = Integer.valueOf(request.getParameter("id"));
        String name =request.getParameter("name");
        Double salary = Double.valueOf(request.getParameter("salary"));
        Integer age = Integer.valueOf(request.getParameter("age"));

        //创建实体类
        Emp emp = new Emp(id,name,salary,age);
        IEmpService empService = new EmpServiceImpl();
        empService.modify(emp);

    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        doPost(request,response);
    }
}
